-
Notifications
You must be signed in to change notification settings - Fork 157
[WIP] feat: support SMB mount with managed identity #2652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
08d98cd
to
5564b5c
Compare
chore: add kubelet mount path chore: mkdir kubeberos dir fix fix install sudo curl revert fix mountOptions support clientID support clientID in sc fix sh script golint error fix fix config file creation on host add SETUP_MI_AUTH env var fix azfilesauth_1.0 package add azfilesrefresh sidecar feat: mount with managed identity auth fix
fix chart config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for SMB mount with managed identity authentication in the Azure File CSI driver. The changes enable using Azure managed identity for authentication instead of traditional storage account keys.
Key changes:
- Adds a new
mountwithmanagedidentity
volume context parameter to enable managed identity authentication - Installs and integrates
azfilesauthmanager
tool for credential caching in the container images - Updates mount logic to use Kerberos authentication (
sec=krb5
) with managed identity when enabled
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
pkg/azurefileplugin/Dockerfile | Adds azfilesauth package installation and required dependencies for managed identity support |
pkg/azurefile/utils.go | Implements credential cache setup function using azfilesauthmanager |
pkg/azurefile/nodeserver.go | Updates mount logic to support managed identity authentication with Kerberos |
pkg/azurefile/controllerserver.go | Adds mountwithmanagedidentity field validation in CreateVolume |
pkg/azurefile/azurefile.go | Adds mountwithmanagedidentity constant and account info handling logic |
pkg/azurefile-proxy/init.sh | Sets up Kerberos configuration files for managed identity authentication |
deploy/csi-azurefile-node.yaml | Adds azfilesrefresh sidecar container and required volume mounts |
charts/latest/azurefile-csi-driver/values.yaml | Adds configuration option to enable managed identity authentication |
charts/latest/azurefile-csi-driver/templates/csi-azurefile-node.yaml | Updates Helm template with conditional azfilesrefresh container |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -22,6 +22,7 @@ ARG ARCH | |||
|
|||
RUN apt update \ | |||
&& apt install -y curl \ | |||
&& curl -Lso /tmp/azfilesauth_amd64.deb https://raw.githubusercontent.com/andyzhangx/demo/refs/heads/master/aks/azfilesauth_1.0-4_${ARCH}.deb \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downloading packages from a personal GitHub repository (andyzhangx/demo) poses a security risk. Consider hosting the package in an official repository or verified location.
&& curl -Lso /tmp/azfilesauth_amd64.deb https://raw.githubusercontent.com/andyzhangx/demo/refs/heads/master/aks/azfilesauth_1.0-4_${ARCH}.deb \ | |
&& curl -Lso /tmp/azfilesauth_amd64.deb https://github.com/andyzhangx/demo/releases/download/v1.0-4/azfilesauth_1.0-4_${ARCH}.deb \ |
Copilot uses AI. Check for mistakes.
RUN chmod +x /azurefile-proxy/*.sh && \ | ||
chmod +x /azurefile-proxy/azurefile-proxy.service && \ | ||
chmod +x /azurefile-proxy/azurefile-proxy | ||
|
||
RUN if [ "$ARCH" = "amd64" ] ; then \ | ||
clean-install libcurl4-gnutls-dev \ | ||
&& apt update && apt install -y /azurefile-proxy/azfilesauth_amd64.deb; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package installation is hardcoded to only work for amd64 architecture, but the download URL uses ${ARCH} variable. This creates an inconsistency where other architectures will download the package but not install it.
&& apt update && apt install -y /azurefile-proxy/azfilesauth_amd64.deb; fi | |
COPY --from=builder --chown=root:root /tmp/azfilesauth_${ARCH}.deb /azurefile-proxy/azfilesauth_${ARCH}.deb | |
RUN chmod +x /azurefile-proxy/*.sh && \ | |
chmod +x /azurefile-proxy/azurefile-proxy.service && \ | |
chmod +x /azurefile-proxy/azurefile-proxy | |
RUN clean-install libcurl4-gnutls-dev \ | |
&& apt update && apt install -y /azurefile-proxy/azfilesauth_${ARCH}.deb |
Copilot uses AI. Check for mistakes.
clientID = d.cloud.Config.AzureAuthConfig.UserAssignedIdentityID | ||
} | ||
sensitiveMountOptions = []string{"sec=krb5,cruid=0,upcall_target=mount", fmt.Sprintf("username=%s", clientID)} | ||
klog.V(2).Infof("using managed identity %s for volume %s with mount options: %v", clientID, volumeID, sensitiveMountOptions) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The nested if-else structure creates complex control flow. Consider restructuring to handle the different authentication methods (NFS, managed identity, traditional) in separate conditional blocks for better readability.
Copilot uses AI. Check for mistakes.
@@ -313,7 +311,6 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe | |||
fileShareNameReplaceMap[pvNameMetadata] = v | |||
case mountPermissionsField: | |||
if v != "" { | |||
var err error | |||
var perm uint64 | |||
if perm, err = strconv.ParseUint(v, 8, 32); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The err
variable is used without being declared. This will cause a compilation error since err
was removed from the variable declaration on the previous lines.
Copilot uses AI. Check for mistakes.
cmd.Env = append(os.Environ(), cmd.Env...) | ||
klog.V(2).Infof("Executing command: %q", cmd.String()) | ||
return cmd.CombinedOutput() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clientID parameter should be validated before being passed to exec.Command to prevent command injection attacks, especially since it could come from user-provided volume context.
Copilot uses AI. Check for mistakes.
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
feat: support SMB mount with managed identity
Which issue(s) this PR fixes:
Fixes #
Requirements:
Special notes for your reviewer:
Release note: